/**
 * @author ghp
 * @title 跳跃游戏
 */
class Solution {

    static boolean f = false;

    public boolean canJump(int[] nums) {
        int path = 0;
        bfs(nums, path);
        return f;
    }

    private void bfs(int[] nums, int path) {
        if (path >= nums.length - 1) {
            // 说明可以到达最后一个元素，结束递归
            f = true;
            return;
        }
        for (int i = 1; i <= nums[path]; i++) {
            // 遍历下一层
            bfs(nums, path + i);
        }
    }
}